#!/usr/bin/env lua

function time2()
    print "enter a number:"
    n = assert(io.read("*number"),"invalid input")
    return n * 2
end

-- 1 exit on error
-- print (time2())


-- 2 error info
-- status,result_or_err = pcall(time2)
-- print (status,result_or_err)

-- 3 detail info
status,result_or_err = xpcall(time2,debug.traceback)
print (status,result_or_err)

print "after error"

-- try input 2 , abc